﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Collections.ObjectModel;

namespace RZD_maps.Modules.Transport.Models
{
    public class TransportCategory
    {
        private readonly ObservableCollection<TransportCategory> subCategories = new ObservableCollection<TransportCategory>();

        private string categoryName = String.Empty;

        private TransportCategory parentCategory;

        /// <summary>
        /// The nested categories.
        /// </summary>
        public ObservableCollection<TransportCategory> SubCategories
        {
            get { return subCategories; }
        }

        /// <summary>
        /// The name of the category. This sample also used
        /// the name as the category key.
        /// </summary>
        public string CategoryName
        {
            get { return categoryName; }
            set { categoryName = value; }
        }

        /// <summary>
        /// The parent category, if any. If this is
        /// a top-level category, this property returns null.
        /// </summary>
        public TransportCategory ParentCategory
        {
            get { return parentCategory; }
            set { parentCategory = value; }
        }

        /// <summary>
        /// Creates a category without a parent.
        /// </summary>
        /// <param name="categoryName">The category's name.</param>
        public TransportCategory(string categoryName) : this(categoryName, null)
        {
        }

        /// <summary>
        /// Creates a category for a given parent. This sets the
        /// <see cref="ParentCategory"/> reference, but does not
        /// automatically add the category to the parent's
        /// <see cref="SubCategories"/> collection.
        /// </summary>
        /// <param name="categoryName">The category's name.</param>
        /// <param name="parentCategory">The parent category, if any.</param>
        public TransportCategory(string categoryName, TransportCategory parentCategory)
        {
          this.categoryName = categoryName;
          this.parentCategory = parentCategory;
        }

        public double Lng { get; set; }
        public double Lat { get; set; }
        public int Id { get; set; }

        /// <summary>
        /// Returns a string with the <see cref="CategoryName"/>.
        /// </summary>
        /// <returns>The category name.</returns>
        public override string ToString()
        {
            return "Category: " + categoryName;
        }

    }
}
